import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration

def generate_launch_description():
    # 获取参数文件的路径
    ros_param_file = LaunchConfiguration('ros_param_file')

    declare_ros_param_file_cmd = DeclareLaunchArgument(
        'ros_param_file',
        default_value=os.path.join(
            get_package_share_directory('image_publisher_pkg'),
            'config',
            'ros.yaml'),
        description='ROS 参数文件的完整路径。'
    )

    # 启动 yolo_detect_pkg 节点
    image_publisher_pkg = Node(
        package='image_publisher_pkg',
        executable='image_publisher_pkg_node',
        name='image_publisher_pkg_node',
        output='screen',
        parameters=[ros_param_file]
    )

    return LaunchDescription([
        declare_ros_param_file_cmd,
        image_publisher_pkg,
    ])
